Repository navigation
fix(ios): answer Safari's "Open in" prompt and inner-panel SpringBoard alerts - #4001
Conversation
Size Report
Startup median (7 runs, lower is better):
|
There was a problem hiding this comment.
All reported issues were addressed across 5 files
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 6 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
|
I reviewed 07cb4a8. The code change looks right, but nothing shows yet that it answers an inner-panel alert and verifies the result truthfully. The only live foldable run is at c84f8d5. That commit tapped through the hosting window but still verified with the old observation, which used the SpringBoard app frame (outer panel) as the viewport for every descendant (RunnerTests+AlertObservation.swift#L69). An inner-panel alert was always observed as absent, so Not blocking, and fine to take or leave: the rule that a SpringBoard modal is visible relative to its own hosting window now lives in two places, Of the open inline threads, the one on the dismissPopup window visibility check still applies (#4001 (comment)). It predates this PR and is off the SpringBoard route it fixes, so please either fix it here or reply on the thread with why it can wait. Two do not apply and can be resolved: the finite-frame check in SystemModal.swift keeps the base behavior, and Alert.swift validates the frame before any tap (#4001 (comment)); the width/height guard in SynthesizedGesturePolicy.swift is the base guard moved verbatim (#4001 (comment)). CI is green: 16 checks, none failing, on 07cb4a8. CI cannot reach the foldable multi-window route, so green says nothing about the changed device path. I had no foldable simulator, so the 466x678 outer-window claim and the inner-panel placement are unverified on my side, and I did not check that the rotation mapping handles an absolute inner-panel point for a non-origin window in a rotated orientation. I also could not tell whether the wider viewport makes more than one SpringBoard candidate visible on a Duo, which would make verification report unconfirmed. Before merge, please attach the unfolded iPhone Duo run above, plus the folded and single-screen iPhone checks. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Addressed at 3369c71.
|
|
There was a problem hiding this comment.
All reported issues were addressed across 6 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
|
The earlier review at 07cb4a8 asked for live evidence and had open geometry questions; the code at ac82af3 now addresses the geometry ones, but the inner-panel SpringBoard route is still not shown to work on a device. Fixed since then: alertSnapshots matches a window against its own frame before it descends, isBlockingSystemModal goes through isPlaced, activateAlertButton refuses with .unsupported when the host window frame is invalid, and the gesture guard uses SnapshotGeometry.isPositiveFinite. The two docs/help threads are also addressed. What remains: there is no live run on a foldable at a commit that has the per-window verification (7bb7062 and later). The PR body says it was not rerun at head because "Duo SpringBoard taps go to its 223x317 status-bar window". Does that routing also affect the alert path (alert.window from springboard.windows.containing(.alert), see https://github.com/callstack/agent-device/blob/ac82af3/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AlertObservation.swift#L69)? If it does, a misrouted tap ends in ALERT_DEADLINE_EXCEEDED or a false success, and the title and body claim more than is shown. Please run alert get, alert dismiss (or accept), then alert get again on the unfolded iPhone Duo simulator at ac82af3, with a SpringBoard alert on the inner panel (alert center x beyond 466). Attach the AGENT_DEVICE_RUNNER_ALERT_ACTIVATION point, the synthesized dispatch referenceFrame equal to the inner window (951x669, not 223x317 or 466x678), dismiss ok, ALERT_NOT_FOUND afterwards, and a screenshot. Repeat folded and on a single-screen iPhone. If the routing does hit this path, could you scope the title and body to Safari and land the SpringBoard part with the ADR 0025 resolver? The Safari before/after runs are described in the PR body but have no logs or screenshots attached. Not blocking, take or leave: no unit test reaches the new .safariDialog source (https://github.com/callstack/agent-device/blob/ac82af3/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Alert.swift#L60), so a snapshot-level test that alertSnapshots(source: .safariDialog) matches an SFDialogView node and ignores an .alert node, or a note that coverage is device-only, would help. I did not run a simulator or the unit tests, so I could not confirm that Safari's prompt is an otherElement with identifier SFDialogView, that RunnerAlertButtonChoice picks Open/Cancel correctly, or whether an SFSafariViewController inside a third-party app exposes the dialog through that app's tree. The open inline threads #4001 (comment), #4001 (comment), #4001 (comment) and #4001 (comment) (window-frame matching, modal placement, host-window guard, finite-frame guard) are fixed at ac82af3, as are #4001 (comment) (commands.md scope) and #4001 (comment) (Alerts help); please resolve them. CI is not finished: Smoke Tests is still running, and Vercel (agent-device-website) fails. The diff touches one prose line in website/docs/docs/commands.md:435 that Vercel builds, and Vercel was green at 07cb4a8 before that line existed, so please check the Vercel log. Neither job reaches the foldable runner path. Before merge, attach the Duo run at ac82af3 (or narrow the PR to Safari), add the folded and single-screen checks, and get Smoke and Vercel green. |
…anel A foldable's SpringBoard has windows on each panel, but springboard.frame names only the outer one. The blocking-modal probe dropped an alert whose center lay outside that frame, so an "Open in" launch confirmation on the unfolded iPhone Duo's inner panel read as absent, and alert get/accept answered ALERT_NOT_FOUND for every session app other than SpringBoard. The activation tap also routed through SpringBoard's first window, the dark outer panel, so even a found alert was never answered. The probe now finds each alert or sheet through the SpringBoard window that hosts it, places it against that window, and routes the alert activation through the same window's display. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The post-tap observation placed SpringBoard alerts against the application frame, which on a foldable names one panel, so an alert on the other panel read as gone right after any tap. Each window now bounds what it hosts. The probe also stops between windows once its deadline is spent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An alert resolved through its SpringBoard host window no longer falls back to the owner app's first window when that window's frame cannot be read; on a foldable that fallback is another panel. The activation reports the refusal instead. The host window is an immutable field, the frame validation is shared through SynthesizedCoordinateContext(validating:), and the modal probe checks its deadline before each modal it reads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The probe and the post-tap observation each decided whether a modal sits in the window hosting it. One pure rule now owns that decision, rejects non-finite frames, and judges a window against its own frame, so a dismiss popup window on a foldable's other panel is no longer read as absent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Safari draws its page prompts as an SFDialogView, not an alert, so `alert` reported "alert not found" while the prompt was on screen, on every iPhone. The runner now finds the dialog by that identifier and verifies its answer against the same surface. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ac82af3 to
8cf03e5
Compare
There was a problem hiding this comment.
All reported issues were addressed across 2 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
…test Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Rebased on main. Head is 428c5ff, and Inner-panel SpringBoard route, run live. The alert path doesn't use the status-bar window that coordinate taps hit. The tap goes through the window that contains the alert. To raise SpringBoard's own "Open in “Agent Device Tester”?" alert, I ran
Safari prompt (
I can't attach the screenshots from the CLI. I checked each one: the alert is present before the action and gone after. I'm happy to share them another way. Unit test. Taken. Title. I kept the SpringBoard part, since the runs above show the alert path works on both panels. ADR 0025 remains the follow-up for SpringBoard coordinate taps, viewport and capture. Open. I haven't checked how SFSafariViewController behaves inside a third-party app. Its dialog may live in the remote SafariViewService process. |
Apex SentinelVerdict: 6 finding(s): 1 major, 2 minor, 3 nit. Verdict: request_changes. reached max rounds (1). Required fixes
🟠 Major (1)
🟡 Minor (2)
🔵 Nit (3)
Reply under an inline comment with |
There was a problem hiding this comment.
Apex Sentinel: 6 new findings on 428c5ff. The verdict and the full list are in the summary comment.
| ) -> [XCUIElementSnapshot] { | ||
| let frame = snapshot.frame | ||
| let visible = !frame.isNull && !frame.isEmpty && viewport.contains(CGPoint(x: frame.midX, y: frame.midY)) | ||
| let hostWindow = snapshot.elementType == .window && SnapshotGeometry.isPositiveFinite(frame) ? frame : viewport |
There was a problem hiding this comment.
🟠 Major · Placement guard for a dismiss-popup window is self-referential and can never reject a candidate
alertSnapshots now derives the containment box from the node being matched: for a .window snapshot with a positive finite frame, hostWindow = snapshot.frame (line 57). The .dismissPopup case matches only snapshot.elementType == .window (line 67), so whenever that match succeeds the box the node is tested against is the node's own frame, and Self.isPlaced(frame, in: frame) (line 69) is true for every positive finite frame — a rectangle's center is always inside it. The visibility read the predecessor had, viewport.contains(center) against the owner app's snapshot frame, is therefore gone for exactly the one source whose candidate is a window: no marked window can be refused for placement any more, including one offset off screen or on the foldable's other panel, and the recursion also hands every descendant that new per-window box.
| let hostWindow = snapshot.elementType == .window && SnapshotGeometry.isPositiveFinite(frame) ? frame : viewport | |
| func alertSnapshots( | |
| in snapshot: XCUIElementSnapshot, | |
| source: RunnerAlertSource, | |
| viewport: CGRect | |
| ) -> [XCUIElementSnapshot] { | |
| let frame = snapshot.frame | |
| let isWindow = snapshot.elementType == .window && SnapshotGeometry.isPositiveFinite(frame) | |
| let hostWindow = isWindow ? frame : viewport | |
| // A window candidate is placed against the box it was enumerated in, never against itself. | |
| let placementBox = (isWindow && source == .dismissPopup) ? viewport : hostWindow | |
| let matches: Bool | |
| switch source { | |
| case .blockingSystemModal: | |
| matches = snapshot.elementType == .alert || snapshot.elementType == .sheet | |
| case .appAlert: | |
| matches = snapshot.elementType == .alert | |
| case .safariDialog: | |
| matches = snapshot.identifier == Self.safariDialogIdentifier | |
| case .dismissPopup: | |
| matches = isWindow && containsDismissPopupMarker(snapshot) | |
| } | |
| if matches && Self.isPlaced(frame, in: placementBox) { return [snapshot] } | |
| return snapshot.children.flatMap { alertSnapshots(in: $0, source: source, viewport: hostWindow) } | |
| } |
Suggested change
Keep the placement test anchored to the viewport the candidate was enumerated against when the candidate itself is the host window: pass the incoming viewport (not the node's own frame) as the box for the .dismissPopup window match, or track the outermost/owner viewport separately so a window candidate is still tested against the app's visible frame.
Details
Failing sequence: alert dismiss on a popup whose owner app's snapshot still carries a marked window outside the visible panel (a popover window SpringBoard/app keeps off-panel or at an offset position, which is what this PR's Duo work shows exists). Before, that window failed the viewport test, the walk found no candidate, the observation was .absent, and the command returned dismissed. Now it is a candidate whose presentation is unchanged, so the verification loop at RunnerTests+Alert.swift:124-137 spins on .stillVisible to the deadline and answers ALERT_DEADLINE_EXCEEDED / INTERACTION_FAILED with activated: true after the tap already went out. Two such windows (one per panel) additionally trip guard candidates.count <= 1 at line 45 and make the whole observation unavailable (ALERT_CONFIRMATION_UNAVAILABLE). No test covers .dismissPopup placement through this path; the new test in RunnerTests+AlertObservationTests.swift covers only .safariDialog and .appAlert.
Also raised here
Also raised at this location by swift-ios: Placement gate in alertSnapshots is vacuous for the .dismissPopup source — alertSnapshots now computes hostWindow as the snapshot's own frame whenever snapshot.elementType == .window and that frame is positive-finite (RunnerTests+AlertObservation.swift:57), and then requires Self.isPlaced(frame, in: hostWindow) (line 69). For source == .dismissPopup, matches is true only when snapshot.elementType == .window && containsDismissPopupMarker(snapshot) (lines 66-67) — i.e. the only snapshots that can match are exactly the ones for which hostWindow was just set to their own frame. The containment test therefore compares a window's center with its own rect and can never fail; isPlaced reduces to SnapshotGeometry.isPositiveFinite(frame), which is already the first clause. The predecessor passed the application snapshot frame down unchanged, so a dismiss-popup window whose center fell outside the app frame was refused as not visible. …
persona: swift-ios, senior-developer
Reply @apex-sentinel-staging note ... to add context, or @apex-sentinel-staging pivot ... if this is wrong — I will re-check the cited code.
Useful? Reply @apex-sentinel-staging like, or @apex-sentinel-staging dislike <why> if it is not.
| return firstBlockingSystemModal(in: springboard, matching: .sheet, deadline: deadline) | ||
| } | ||
|
|
||
| private func firstBlockingSystemModal( |
There was a problem hiding this comment.
🟡 Minor · Blocking system modal discovery now requires the modal to sit inside a SpringBoard window
firstBlockingSystemModal used to enumerate springboard.alerts / springboard.sheets directly, so any alert- or sheet-shaped element in SpringBoard's tree was a candidate regardless of where it sat. The replacement enumerates springboard.windows.containing(type, identifier: nil) and then window.descendants(matching: type), so a modal that XCTest surfaces directly under the application element (not under a windows child) is now invisible to the probe, and alert get/accept/dismiss and the blocking-system-modal snapshot report ALERT_NOT_FOUND/nil for it. This is the same discovery path the alert command's public iOS behavior depends on, so a regression here is user-visible. The PR's device validation covered SpringBoard openurl prompts only; no unit or fixture test pins a modal outside a window (the new test exercises only Self.isPlaced). If the window-nested assumption is intended, the probe should keep a fallback over springboard.alerts/sheets when no window candidate matches, and the assumption should be stated in the comment above SpringBoardModal.
Suggested change
Confirm on a device that every SpringBoard modal the probe previously matched is nested under a windows child; otherwise add a fallback to the old springboard.alerts/springboard.sheets enumeration when no window-hosted candidate resolves, and add a fixture test for a modal that is not under a window.
Details
Also raised here
Also raised at this location by senior-developer: Unanswered launch confirmations are no longer surfaced when the panel window names no alert or sheet — firstBlockingSystemModal changed the enumeration from the app-level queries springboard.alerts / springboard.sheets to springboard.windows.containing(type, identifier: nil) (line 136) and only then reads window.descendants(matching: type). A modal that XCTest reports through app.alerts/app.sheets but that is not a descendant of a window node — or sits in a window whose own frame is null/empty, which isBlockingSystemModal then refuses via isPlaced (line 162, 168) — is no longer found at all. The predecessor tested the element's center against springboard.frame and had no window prerequisite, so such a modal was resolved. This regresses the behavior commit 3d91901 ("report the alert's own title and surface an unanswered launch confirmation", #3732) added: an unanswered launch confirmation must be surfaced, and with it the caller now gets ALERT_NOT_FOUND on a screen that visibly blocks the device. …
persona: javascript, senior-developer
Reply @apex-sentinel-staging note ... to add context, or @apex-sentinel-staging pivot ... if this is wrong — I will re-check the cited code.
Useful? Reply @apex-sentinel-staging like, or @apex-sentinel-staging dislike <why> if it is not.
| } | ||
|
|
||
| private func alertSnapshots( | ||
| func alertSnapshots( |
There was a problem hiding this comment.
🟡 Minor · hostWindow widens from a placement check to an origin for every window-shaped snapshot
In alertSnapshots the host frame is taken from any snapshot whose elementType is .window, but .window is also the matching shape for .dismissPopup, and the recursion now overwrites viewport with that frame for all children. Two consequences: (1) a popup window that matches .dismissPopup is measured against its own frame, so isPlaced is self-referential and always true — the old viewport.contains(center) rejection of a window sitting outside the app's reported frame (a zero-height or off-panel SpringBoard window) is gone; (2) once one window frame is adopted it is never restored for sibling branches, and on the Duo SpringBoard's first window is the 223x317 status-bar window this PR's own description names, so modals below it are checked against that tiny box, or against a window frame on the wrong panel, and are dropped as not placed. Pass the viewport down unchanged and use the window frame only as the host for the one snapshot that is the window.
Suggested change
Keep viewport as the parameter passed to the recursive call, and compare a window-shaped snapshot against the viewport while comparing its descendants against that window's frame.
Details
persona: maintainability
Reply @apex-sentinel-staging note ... to add context, or @apex-sentinel-staging pivot ... if this is wrong — I will re-check the cited code.
Useful? Reply @apex-sentinel-staging like, or @apex-sentinel-staging dislike <why> if it is not.
| return | ||
| } | ||
| switch synthesizedTapAt(app: alert.ownerApp, x: frame.midX, y: frame.midY, deadline: deadline) { | ||
| var hostContext: SynthesizedCoordinateContext? |
There was a problem hiding this comment.
🔵 Nit · New alert-activation failure path has no test
activateAlertButton gains a new refusal: when alert.window is set but its frame read fails (safely("ALERT_WINDOW", CGRect.null) yields a non-positive-finite box), the command returns .unsupported("alert activation could not read the window hosting the alert") instead of tapping. The sibling pre-synthesis refusal in the same function (missing _waitForQuiescenceAsPreEvent:) and the deadline paths are pinned by RunnerTests+AlertObservationTests, but this new branch is not, and the file already carries the stubbing hooks (alertResolutionOverrideForTesting, AlertTapDeadlineStub) needed to reach it.
Suggested change
Add a unit test that resolves an alert whose window frame read throws or returns CGRect.null and asserts the unsupported outcome and that no tap was synthesized.
Details
persona: javascript
Reply @apex-sentinel-staging note ... to add context, or @apex-sentinel-staging pivot ... if this is wrong — I will re-check the cited code.
Useful? Reply @apex-sentinel-staging like, or @apex-sentinel-staging dislike <why> if it is not.
| } | ||
| } | ||
|
|
||
| extension SynthesizedCoordinateContext { |
There was a problem hiding this comment.
🔵 Nit · SynthesizedCoordinateContext now validates with a stricter box guard than the code it replaced
The inline guard in synthesizedCoordinateContext (isFinite + width/height > 0) was replaced by SnapshotGeometry.isPositiveFinite (RunnerTests+SynthesizedGesturePolicy.swift:201). The new guard also refuses CGRect.infinite and a finite box whose maxX/maxY overflow, and it checks all four coordinates' finiteness, not just the extents. That is a behavior change on the shared coordinate route: a previously accepted reference frame now yields nil, i.e. synthesizedTapAt answers "could not resolve an app window with a finite screen frame". The change is in the safer direction and matches the kernel/Swift twin rule cited in SnapshotGeometry.swift, but it is worth one comment saying the shared route intentionally uses the stricter box guard, since the two guards are not equivalent.
Details
persona: senior-developer
Reply @apex-sentinel-staging note ... to add context, or @apex-sentinel-staging pivot ... if this is wrong — I will re-check the cited code.
Useful? Reply @apex-sentinel-staging like, or @apex-sentinel-staging dislike <why> if it is not.
|
|
||
| private func safeIsBlockingSystemModal(_ element: XCUIElement, in springboard: XCUIApplication) -> Bool { | ||
| safely("MODAL_CHECK", false) { isBlockingSystemModal(element, in: springboard) } | ||
| private func safeIsBlockingSystemModal(_ element: XCUIElement, in window: XCUIElement) -> Bool { |
There was a problem hiding this comment.
🔵 Nit · isBlockingSystemModal keeps its name after becoming a placement test
Renaming the parameter from springboard to window and replacing the three guard clauses with one isPlaced call leaves the name promising more than the function now decides: existence and placement only, nothing about modality or blocking. safeIsBlockingSystemModal and firstBlockingSystemModal inherit the same drift two layers up.
Suggested change
Rename to something like isPresentedInWindow (and the same for the safe/first… wrappers) or state in the doc comment that blocking-ness is decided by the caller.
Details
persona: maintainability
Reply @apex-sentinel-staging note ... to add context, or @apex-sentinel-staging pivot ... if this is wrong — I will re-check the cited code.
Useful? Reply @apex-sentinel-staging like, or @apex-sentinel-staging dislike <why> if it is not.
|
The code looks good at 428c5ff. It fixes the open items from the earlier review (#4001 (comment)): the live evidence is now in the PR, and Smoke and Vercel now pass. Not blocking, and fine to take or leave: the PR body calls the Safari runs at 3369c71 "same runner code", but the rebase changed the shared button chooser to The live evidence is log lines transcribed by the author, without screenshots or raw runner logs. I did not run a simulator or the unit tests. Of the six Apex Sentinel threads, five do not apply and can be replied to and resolved: #4001 (comment) (window candidate placed against its own frame on purpose, as an earlier P1 asked), #4001 (comment) (modals are found through the windows that host them; the live alert was found this way on three devices), #4001 (comment) (hostWindow is computed per call, so siblings do not inherit the parent's box), #4001 (comment) (the stricter finite-frame guard is the fix an earlier P2 asked for), and #4001 (comment) (base already checked the same conditions, so the name did not drift). The sixth, #4001 (comment), is a non-blocking nit about an untested refusal branch. The Cubic P3 thread #4001 (comment) is fixed at head and already resolved. CI is 20 of 21 green. The one check not passing is the Apex Sentinel review check, which is a request for changes, not a build or test job, and its one required fix does not apply. Replying on and resolving those threads should clear that check. The open question on how SFSafariViewController inside a third-party app exposes SFDialogView is still with the author. |
Summary
Two prompts answered
ALERT_NOT_FOUNDwith "Open … in “App”?" on screen:SFDialogView, not an alert, so it failed on every iPhone. The runner now finds it by that identifier and checks the answer against it.openurl) was missed on the Duo's inner panel:springboard.framenames only the outer panel (466×678). Each SpringBoard alert is now placed, tapped and checked in its own window. An unreadable window refuses the tap.Validation
pnpm check:affected --run --head 428c5ff490: passed.alert get→dismiss/accept→alert get(ALERT_NOT_FOUND), with screenshots. SpringBoard: rebased head. Safari:3369c71c01(same runner code):ALERT_NOT_FOUND)Follow-up: SpringBoard coordinate taps, viewport and capture still use its first window (a 223×317 status-bar window on the Duo). Alert taps don't, because they route through the alert's own window. Fixing the rest needs a panel-aware SpringBoard window resolver (ADR 0025).
🤖 Generated with Claude Code